<?php
	include_once '../includes/header.php';	
	include_once '../includes/menu.php';
?>
<div id="content">
	
	<h2> Lista de Im&oacute;veis</h2>
	   <a href="imovelIncluir.php" ><img src="../assets/icones/add.png" /></a>
    
	   <table class="display" id="example">
            <thead>
                <tr>		
                	<th>Foto</th>
                	<th>Propriet&aacute;rio  </th>
                    <th>Endere&ccedil;o </th>
                    <th>Cidade </th>                    
                	<th>Neg&oacute;cio </th>
                   	<th>Tipo Im&oacute;vel </th>
                    <th>Consultar</th>
                    <th>Editar</th>
                    <th>Excluir</th>
                    
                </tr>
                
            </thead>
            <tbody>
            <?php        	 	
				require_once '../classes/banco.class.php';
           	 	
           	 	$banco = new banco();
				$banco->conecta();
				$resultado=$banco->exSQL("SELECT i.id, i.endereco, i.aluguel, i.venda, p.nome, c.descricao, t.nome_tipo
											FROM imovel i
											INNER JOIN pessoa p ON i.pessoa_id = p.id
											INNER JOIN cidade c ON i.cidade_id = c.id
											INNER JOIN tipo_imovel t ON i.tipo_imovel_id = t.id  ");
											
											
        		while($campo = mysql_fetch_array($resultado)){
					$id=$campo['id'];				
						
            	?>
                    <tr>
                    	<td><img src="<?php echo "../fotosImoveis/$id/frente.jpg"; ?>" width="100"/></td>
                        <td>
                            <?php echo $campo['nome'];	?>
                        </td>
                        <td>
                            <?php echo $campo['endereco'];?>
                        </td>
                     
                        <td>
                            <?php echo $campo['descricao'];?>
                        </td>
                        <td>
                            <?php 
	                            if ($campo['aluguel']==1){echo "Aluguel "; }
	                            if ($campo['venda']==1){echo "Venda "; }                            
	                           ?>
                        </td>
                        <td>
                            <?php echo $campo['nome_tipo'];?>                        	
                        </td>                        
                        </td>
                         <td>
                            <a  href="imovelConsulta.php?id=<?php echo $campo['id'];  ?>">
                                <img src="../assets/icones/consultar.png" alt="Consultar" />
                            </a>
                        </td>
                         <td>
                            <a alt="imovelEdita<?php echo $campo['id']; ?>" href="imovelEditar.php?id=<?php echo $campo['id']; ?>">
                                <img src="../assets/icones/editar.png" />
                            </a>
                        </td>
                        <td>
                            <a href="imovelExcluir.php?id=<?php echo $campo['id'];  ?>">
                                <img src="../assets/icones/excluir.png" />
                            </a>
                        </td>
                    
                    </tr>
                    
                <?php } ?>	           			
			</tbody>
			
	</table>	
	</div>
	<?php	
	include_once '../includes/footer.php';
?>